home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000…tember: Reference Library / Dev.CD Sep 00 RL Disk 1.toast / mac / Technical Documentation / Develop / develop Issue 28 / develop Issue 28 code / CurveLayout / AccurateShapesLibrary / tests / TestBendDash.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-30  |  2.8 KB  |  129 lines  |  [TEXT/CWIE]

  1. #include <GXGraphics.h>
  2. #include "AccurateShapes.h"
  3.  
  4. /************************
  5.  
  6.     Wrapper for GXGetShapeLength
  7.     which returns a fixed point value.
  8.  
  9. ************************/
  10. Fixed        ClGetFixedShapeLength(gxShape theShape);
  11. Fixed        ClGetFixedShapeLength(gxShape theShape)
  12.     {
  13.         wide            wLength;
  14.         Fixed            pathLength;
  15.                 
  16.         GXGetShapeLength(theShape, 0, &wLength);
  17.         pathLength = (Fixed)wLength.lo;
  18.     
  19.         return(pathLength);
  20.     
  21.     }//ClGetFixedShapeLength
  22.     
  23.  
  24. gxShape MakeThePath(void);
  25. gxShape MakeThePath(void)
  26.     {
  27.         static                 gxCurve            curveGeometry = {ff(50), ff(325), ff(175), ff(150), ff(300), ff(325) };
  28.         static                 gxCurve            curveGeometry2 = {ff(300), ff(325), ff(425), ff(500), ff(550), ff(325) };
  29.         gxShape                nicePath;
  30.         gxShape                curve2;
  31.     
  32.         nicePath = GXNewCurve(&curveGeometry);
  33.         GXSetShapeType(nicePath, gxPathType);
  34.         curve2= GXNewCurve(&curveGeometry2);
  35.         GXSetShapeParts(nicePath, 0, 0, curve2, gxBreakNeitherEdit);
  36.         GXDisposeShape(curve2);
  37.         
  38.         GXSetShapeFill(nicePath, gxFrameFill);
  39.         
  40.         GXMoveShape(nicePath, ff(0), ff(-120));
  41.     
  42.         return(nicePath);    
  43.     }
  44.  
  45.  
  46. gxShape MakeDashShape(gxShape thePath);
  47. gxShape MakeDashShape(gxShape thePath)
  48.     {
  49.         char        polydata[100];
  50.         gxPolygons    *thePoly = (gxPolygons*)polydata;
  51.         long        *aLong;
  52.         gxPoint        *aPoint;
  53.         char        *p = polydata;
  54.         
  55.         aLong = (long*)p;
  56.         *aLong = 3;                // number of countours;
  57.         p += sizeof(aLong);
  58.         aLong = (long*)p;
  59.         *aLong = 2;                // points in first contour;
  60.         p += sizeof(long);
  61.         aPoint = (gxPoint*)p;
  62.         aPoint->x = ff(50);
  63.         aPoint->y = ff(0);
  64.         p += sizeof(gxPoint);
  65.         
  66.         aPoint = (gxPoint*)p;
  67.         aPoint->x = ff(100);
  68.         aPoint->y = ff(0);
  69.         p += sizeof(gxPoint);
  70.         
  71.         aLong = (long*)p;
  72.         *aLong = 2;                // points in second countour;
  73.         p += sizeof(long);
  74.         aPoint = (gxPoint*)p;
  75.         aPoint->x = ff(150);
  76.         aPoint->y = ff(0);
  77.         p += sizeof(gxPoint);
  78.         
  79.         aPoint = (gxPoint*)p;
  80.         aPoint->x = ff(250);
  81.         aPoint->y = ff(0);
  82.         p += sizeof(gxPoint);
  83.         
  84.         aLong = (long*)p;
  85.         *aLong = 2;                // points in second countour;
  86.         p += sizeof(long);
  87.         aPoint = (gxPoint*)p;
  88.         aPoint->x = ff(300);
  89.         aPoint->y = ff(0);
  90.         p += sizeof(gxPoint);
  91.         
  92.         aPoint = (gxPoint*)p;
  93.         aPoint->x = ClGetFixedShapeLength(thePath);
  94.         aPoint->y = ff(0);
  95.         p += sizeof(gxPoint);
  96.         
  97.         
  98.         return(GXNewPolygons(thePoly));
  99. }        
  100.  
  101. main() {
  102.  
  103.     gxShape            thePath = MakeThePath();
  104.     gxDashRecord    aDash;
  105.     gxColor            aColor;
  106.     gxShape            dashShape;
  107.     
  108.     
  109.     GXDrawShape(thePath);
  110.  
  111.     dashShape = MakeDashShape(thePath);
  112.     aDash.dash = dashShape;
  113.     aDash.attributes = gxBendDash;
  114.     aDash.phase = 0;
  115.     aDash.advance = 0;
  116.     GXSetShapeDash(thePath, &aDash);
  117.     GXDisposeShape(dashShape);
  118.     
  119.     AccuratePrimitiveShape(thePath);
  120.     GXSetShapeDash(thePath, nil);
  121.     
  122.     aColor.space = gxRGBSpace;
  123.     aColor.profile = nil;
  124.     aColor.element.rgb.red = 0;
  125.     aColor.element.rgb.green = 0xFFFF;
  126.     aColor.element.rgb.blue = 0;
  127.     GXSetShapeColor(thePath, &aColor);
  128.     GXDrawShape(thePath);
  129. }